package com.example.imtoken.modules.main

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.example.imtoken.modules.main.browse.BrowseFragment
import com.example.imtoken.modules.main.my.MyFragment
import com.example.imtoken.modules.main.wallet.WalletFragment

class MainFragmentAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
    FragmentStateAdapter(fragmentManager, lifecycle) {
    override fun getItemCount(): Int {
        return 3
    }

    override fun createFragment(position: Int): Fragment {
        return when (position) {
            0 -> WalletFragment()
            1 -> BrowseFragment()
            2 -> MyFragment()
            else -> throw Exception("没有更多的Fragment")
        }
    }
}